<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改站点')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-site-edit" th:object="${databandSite}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="deptid" type="hidden" id="treeId"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label">站点编码：</label>
                <div class="col-sm-8">
                    <input name="code" th:field="*{code}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">站点名称：</label>
                <div class="col-sm-8">
                    <input name="title" th:field="*{title}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">所属部门：</label>
                <div class="col-sm-8">
                                      
                      <div class="input-group">
                      	<input name="deptName" th:value="${deptname}" onclick="selectDeptTree()" id="treeName" type="text" maxlength="30"  class="form-control">
                          <span class="input-group-addon"><i class="fa fa-search"></i></span>
                      </div>
                      
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">站点地址：</label>
                <div class="col-sm-8">
                    <input name="url" th:field="*{url}" class="form-control" type="text">
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label">图标：</label>
                <div class="col-sm-8">
                    <input name="icon" th:field="*{icon}" class="form-control" type="text">
                    <div class="ms-parent" style="width: 100%;">
                        <div class="icon-drop animated flipInX" style="display: none;max-height:200px;overflow-y:auto">
                            <div data-th-include="system/menu/icon"></div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                <textarea name="descri" th:field="*{descri}" maxlength="300" class="form-control" rows="3"></textarea>
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "web/site";
        $("#form-site-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-site-edit').serialize());
            }
        }
        
        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
        	var treeId = $("#treeId").val();
        	var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        	var url = ctx + "system/dept/selectDeptTree/" + deptId;
			var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			var body = layer.getChildFrame('body', index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			layer.close(index);
		}
		
        $(function() {
        	
        	$("input[name='icon']").focus(function() {
        		$(".icon-drop").show();
            });
        	$("#form-site-edit").click(function(event) {
        	    var obj = event.srcElement || event.target;
        	    if (!$(obj).is("input[name='icon']")) {
        	    	$(".icon-drop").hide();
        	    }
        	});
        	$(".icon-drop").find(".ico-list i").on("click", function() {
        		$('#icon').val($(this).attr('class'));
            });
        });
        
    </script>
</body>
</html>